package ch03
{

	import flash.display.Sprite;
	import flash.events.Event;
	import utils.Ball;

	//平滑的上下运动
	public class BallTest extends Sprite
	{
		private var ball:Ball;
		private var angle:Number=0;
		private var centerY:Number=200;
		private var range:Number=50;
		private var speed:Number=0.2;

		public function BallTest()
		{
			init();
		}

		private function init():void
		{
			ball=new Ball();
			addChild(ball);
			ball.x=stage.stageWidth / 2;
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}

		// and the handler function:
		public function onEnterFrame(event:Event):void
		{
			ball.y=centerY + Math.sin(angle) * range;
			angle+=speed;
		}
	}
}